﻿using System;
using System.IO;

namespace 第三题
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"C:\Users\24173\Desktop\config.txt";
            IniFile ini = new IniFile();
            ini.ReadFile(path);
            string ip = ini.GetString("连接信息", "主机");
            Console.WriteLine(ip);
        }
    }

    class IniFile
    {
        private string path;
        
        public void ReadFile(string source)
        {
            path = source; 
        }
        public string GetString(string target1,string target2)
        {
            string s = File.ReadAllText(path);
            string[] arr = s.Split("\n");
            for (int i = 0; i < arr.Length; i++)
            {
                if(arr[i].Contains(target2))
                {
                    string[] arr2 = arr[i].Split('=');
                    return arr2[1];
                }
            }
            return "找不到指定参数";
        }
    }
}
